﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/Master/AdminSite.Master"
    AutoEventWireup="true" CodeBehind="UsersManageForm.aspx.cs" Inherits="OMSWeb.Admin.Systems.UsersManageForm" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

    <script type="text/javascript">
        //bind
        var grid = null;
        $(function() {
            grid = $("#maingrid4").ligerGrid({
                height: '100%',
                checkbox: true,
                columns: [{ display: ' 编号', name: 'homeChargeId', type: 'int' },
                { display: '姓名', name: 'handleName' },
                { display: '性别', name: 'startDate', type: 'date' },
                { display: '手机', name: 'handleName' },
                { display: 'Email', name: 'handleName' },
                { display: '店铺名称', name: 'handleName' },
                { display: '会员级别', name: 'handleName' },
                { display: '注册时间', name: 'handleName' },
                { display: '订单总数', name: 'handleName' }
                ],
                toolbar: { items: [


                { text: '修改', click: itemclick, icon: 'modify' },
                { line: true },
                { text: '删除', click: f_getChecked, img: '../../../lib/ligerUI/skins/icons/delete.gif' }
                ]
                },

                url: "../service/DataHandler.ashx?Action=get&View=Home",
                showTitle: false, dataAction: 'server', sortName: 'homeChargeId',
                pageSize: 5,
                pageSizeOptions: [5, 10, 15], where: f_getWhere(),

                isChecked: f_isChecked, onCheckRow: f_onCheckRow, onCheckAllRow: f_onCheckAllRow


            });
        });
        function f_reload() {
            grid.loadData();
        }

        function itemclick(item) {
            alert(item.text);
        }



        function f_onCheckAllRow(checked) {
            for (var rowid in this.records) {
                if (checked)
                    addCheckedCustomer(this.records[rowid]['homeChargeId']);
                else
                    removeCheckedCustomer(this.records[rowid]['homeChargeId']);
            }
        }


        /*
        该例子实现 表单分页多选
        即利用onCheckRow将选中的行记忆下来，并利用isChecked将记忆下来的行初始化选中
        */
        var checkedCustomer = [];
        function findCheckedCustomer(homeChargeId) {
            for (var i = 0; i < checkedCustomer.length; i++) {
                if (checkedCustomer[i] == homeChargeId) return i;
            }
            return -1;
        }
        function addCheckedCustomer(homeChargeId) {
            if (findCheckedCustomer(homeChargeId) == -1)
                checkedCustomer.push(homeChargeId);
        }
        function removeCheckedCustomer(homeChargeId) {
            var i = findCheckedCustomer(homeChargeId);
            if (i == -1) return;
            checkedCustomer.splice(i, 1);
        }
        function f_isChecked(rowdata) {
            if (findCheckedCustomer(rowdata.homeChargeId) == -1)
                return false;
            return true;
        }
        function f_onCheckRow(checked, data) {
            if (checked) addCheckedCustomer(data.homeChargeId);
            else removeCheckedCustomer(data.homeChargeId);
        }
        function f_getChecked() {
            alert(checkedCustomer.join(','));
        }

        function f_getWhere() {
            if (!grid) return null;
            var clause = function(rowdata, rowindex) {
                var key = $("#txtKey").val();
                return rowdata.homeChargeId.indexOf(key) > -1;
            };
            return clause;
        }
        function f_search() {
            //grid.options.data = $.extend(true, {}, CustomersData);
            grid.loadData(f_getWhere());
        }
      
    </script>

    <div id="searchbar" class="message">
        <table class="table">
            <tr>
                <td class="td" align="right">
                    姓名：
                </td>
                <td>
                    <input id="txtKey" type="text" />
                </td>
                <td class="td" align="right">
                    性别：
                </td>
                <td>
                    <input id="Text1" type="text" />
                </td>
                <td>
                    &nbsp;
                </td>
            </tr>
            <tr>
                <td align="right">
                    会员级别：
                </td>
                <td>
                    <input id="Text2" type="text" />
                </td>
                <td align="right">
                    手机：
                </td>
                <td>
                    <input id="Text3" type="text" />
                </td>
                <td>
                    <input id="btnOK" type="button" value="搜 索" onclick="f_search()" class="l-button" />
                </td>
            </tr>
        </table>
    </div>
    <div id="maingrid4">
    </div>
</asp:Content>
